#ifndef READER_H
#define READER_H 1

#include <sys/param.h>

#include "main.h"
#include "string.h"
#include "bool.h"


#ifndef DIRLIST_INITSIZ
# define DIRLIST_INITSIZ 4
#endif

typedef struct array dirlist_t;

typedef struct __ncattr__ dirlist_elem {
  string_t *path;
  string_t *data;
  const char *ext;
  size_t siz;
} dirlist_elem_t;

int
open_file(const char *file_path);

void *
mmap_fd(int fd, size_t *memsize);

string_t *
mmap_fd_str(int fd);

bool
mmap_data(dirlist_elem_t *elem);

dirlist_t *
listfiles(char dir_path[MAXPATHLEN+1], const char *ext, dirlist_t *dptr);

dirlist_elem_t *
listfiles_foreach(dirlist_t *dlist, size_t *idx_ptr);

void
listfiles_cleanup(dirlist_t *dlist);

#endif
